package com.sunwayworld.basemodule.rm.equipment.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.rm.equipment.dao.LimsEquipmentNewmaintainDao;
import com.sunwayworld.basemodule.rm.equipment.bean.LimsEquipmentNewmaintainBean;
import com.sunwayworld.basemodule.rm.equipment.service.LimsEquipmentNewmaintainService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsEquipmentNewmaintainServiceImpl implements LimsEquipmentNewmaintainService {

    @Autowired
    private LimsEquipmentNewmaintainDao limsEquipmentNewmaintainDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsEquipmentNewmaintainDao getDao() {
        return limsEquipmentNewmaintainDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsEquipmentNewmaintainBean limsEquipmentNewmaintain = jsonWrapper.parseUnique(LimsEquipmentNewmaintainBean.class);
        limsEquipmentNewmaintain.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsEquipmentNewmaintain);
        return limsEquipmentNewmaintain.getId();
    }

}
